package com.wiley.loginPO;

import java.net.MalformedURLException;
import java.util.Set;

import org.openqa.selenium.By;

import com.wiley.publicMethod.BasePage;
import com.wiley.publicMethod.LoggerControler;

import io.appium.java_client.android.AndroidDriver;

public class LoginWithWeiboPage extends BasePage {

	/**
	 * 页面元素
	 */
	//我的
	public static final By mine_item_loc = By.id(BaseId + "mine_item");

	//点击登录按钮
	public static final By login_tv_loc = By.id(BaseId + "login_tv");

	//社交账号：微博
	public static final By login_with_weibo_loc = By.id(BaseId+"login_with_weibo");

	/**
	 * 操作方法
	 */
	//点击我的
	public void clickMineItem(){
		this.clickEle(mine_item_loc);
	}

	//登录按钮
	public void clickLoginButton(){
		this.clickEle(login_tv_loc);
	}

	//点击微博账号
	public void clickLoginWithWeibo(){
		this.clickEle(login_with_weibo_loc);
	}
	
	/**
	 * 业务封装
	 * @throws MalformedURLException 
	 */
	//登录
	public void LoginWithWeibo(Class name) throws MalformedURLException  {
		LoggerControler log = this.MyLogger(name);
		AndroidDriver driver = super.SetDriver();
		this.clickMineItem();
		this.clickLoginButton();
		this.clickLoginWithWeibo();
		Set<String> context = driver.getContextHandles();
		for (String contextName : context) {
			System.out.println(contextName);
		}
		//driver.context("WEBVIEW_com.android.browser");
		//安卓4.4版本
		this.sendKeysByIndex(By.className("android.widget.EditText"), 0, "1");
		this.sendKeysByIndex(By.className("android.widget.EditText"), 1, "1");
		this.clickEle(By.name("登录 Link"));
		log.info("该case测试通过");
	}
}
